﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using University.Workshop.DataAccess;
using System.Data;

namespace University.Workshop.Business
{
    public static class DiagnosticManager
    {
        public static bool InsertDiagnosticPatient(Diagnostic diagnostic) 
        {
            return DiagnosticDataAccess.InsertDiagnosticPatient(diagnostic);
        }
        public static DataTable LoadDataGridViewQuery()
        {
            return DiagnosticDataAccess.LoadDataGridViewQuery();
        }

        public static string ObtainNunQuery()
        {
            string nQuery;
            DataSet dataSet = DiagnosticDataAccess.ObtainNunQuery();
            if (dataSet != null)
            {
                nQuery = dataSet.Tables[0].Rows[0][0].ToString();
                return nQuery;
            }
            else
            {
                return null;
            }
        }
        public static DataTable LoadDataGridViewSearchQuery(string searchQuery)
        {
            return DiagnosticDataAccess.LoadDataGridViewSearchQuery(searchQuery);
        }

        public static string LoadDataDiagnosticPatient(string searchPatient)
        {
            string diagnosticData;
            DataSet dataSet = DiagnosticDataAccess.LoadDataDiagnosticPatient(searchPatient);
            if (dataSet != null)
            {
                diagnosticData = "State Treatment :" + dataSet.Tables[0].Rows[0]["StateDiagnostic"].ToString();
                diagnosticData +="  Diagnostic :" + dataSet.Tables[0].Rows[0]["NameDiagnostic"].ToString();
                diagnosticData +="  Treatments :"+ dataSet.Tables[0].Rows[0]["NameTreatment"].ToString();
                diagnosticData +="  Adverse Circumstances :"+ dataSet.Tables[0].Rows[0]["AdverseCircumstances"].ToString();
                return diagnosticData;
            }
            else
            {
                return null;
            }            
        }
    }
}
